﻿using IMDBApi.Contracts;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace IMDBApi.Contracts.Entities.Title.MainDetail
{
    [DataContract]
    public class MainDetail
    {
        [DataMember(Name = "exp")]
        public int Exp { get; set; }

        [DataMember(Name = "@meta")]
        public Meta Meta { get; set; }

        [DataMember(Name = "data")]
        public Data Data { get; set; }

        [DataMember(Name = "copyright")]
        public string Copyright { get; set; }
    }

    [DataContract]
    public class Meta
    {
        [DataMember(Name = "serverTimeMs")]
        public int ServerTime { get; set; }

        [DataMember(Name = "requestId")]
        public string RequestId { get; set; }
    }

    [DataContract]
    public class Data
    {
        [DataMember(Name = "photos")]
        public List<Photo> Photos { get; set; }

        [DataMember(Name = "directors_summary")]
        public List<DirectorsSummary> DirectorsSummary { get; set; }

        [DataMember(Name = "user_comment")]
        public UserComment UserComment { get; set; }

        [DataMember(Name = "certificate")]
        public Certificate Certificate { get; set; }

        [DataMember(Name = "has")]
        public List<string> Has { get; set; }

        [DataMember(Name = "writers_summary")]
        public List<WritersSummary> WritersSummary { get; set; }

        [DataMember(Name = "rating")]
        public double Rating { get; set; }

        [DataMember(Name = "num_votes")]
        public int NumVotes { get; set; }

        [DataMember(Name = "tconst")]
        public string TConst { get; set; }

        [DataMember(Name = "genres")]
        public List<string> Genres { get; set; }

        [DataMember(Name = "best_plot")]
        public BestPlot BestPlot { get; set; }

        [DataMember(Name = "quote")]
        public Quote Quote { get; set; }

        [DataMember(Name = "can_rate")]
        public bool CanRate { get; set; }

        [DataMember(Name = "trailer")]
        public Trailer Trailer { get; set; }

        [DataMember(Name = "release_date")]
        public ReleaseDate ReleaseDate { get; set; }

        [DataMember(Name = "trivium")]
        public string Trivium { get; set; }

        [DataMember(Name = "goof")]
        public string goof { get; set; }

        [DataMember(Name = "image")]
        public Image image { get; set; }

        [DataMember(Name = "tagline")]
        public string Tagline { get; set; }

        [DataMember(Name = "runtime")]
        public Runtime Runtime { get; set; }

        [DataMember(Name = "cast_summary")]
        public List<CastSummary> CastSummary { get; set; }

        [DataMember(Name = "plot")]
        public Plot Plot { get; set; }

        [DataMember(Name = "news")]
        public News News { get; set; }

        [DataMember(Name = "type")]
        public string Type { get; set; }

        [DataMember(Name = "title")]
        public string Title { get; set; }

        [DataMember(Name = "year")]
        public string Year { get; set; }
    }

    [DataContract]
    public class Photo
    {
        [DataMember(Name = "link")]
        public string Link { get; set; }

        [DataMember(Name = "image")]
        public Image Image { get; set; }
    }

    [DataContract]
    public class Image
    {
        [DataMember(Name = "width")]
        public int Width { get; set; }

        [DataMember(Name = "url")]
        public string Url { get; set; }

        [DataMember(Name = "height")]
        public int Height { get; set; }
    }

    [DataContract]
    public class DirectorsSummary
    {
        [DataMember(Name = "name")]
        public Name Name { get; set; }
    }

    [DataContract]
    public class Name
    {
        [DataMember(Name = "nconst")]
        public string nconst { get; set; }

        [DataMember(Name = "name")]
        public string Names { get; set; }

        [DataMember(Name = "image")]
        public Image Image { get; set; }
    }

    [DataContract]
    public class UserComment
    {
        [DataMember(Name = "user_rating")]
        public int UserRating { get; set; }

        [DataMember(Name = "status")]
        public string Status { get; set; }

        [DataMember(Name = "date")]
        public string Date { get; set; }

        [DataMember(Name = "user_name")]
        public string UserName { get; set; }

        [DataMember(Name = "summary")]
        public string Summary { get; set; }

        [DataMember(Name = "user_score")]
        public int UserScore { get; set; }

        [DataMember(Name = "text")]
        public string Text { get; set; }

        [DataMember(Name = "user_location")]
        public string UserLocation { get; set; }

        [DataMember(Name = "user_score_count")]
        public int UserScoreCount { get; set; }
    }

    [DataContract]
    public class Certificate
    {
        [DataMember(Name = "certificate")]
        public string Certificates { get; set; }

        [DataMember(Name = "attr")]
        public string Attr { get; set; }
    }

    [DataContract]
    public class WritersSummary
    {
        [DataMember(Name = "name")]
        public Name Name { get; set; }

        [DataMember(Name = "attr")]
        public string Attr { get; set; }
    }

    [DataContract]
    public class BestPlot
    {
        [DataMember(Name = "outline")]
        public string Outline { get; set; }

        [DataMember(Name = "total_summaries")]
        public int TotalSummaries { get; set; }
    }

    [DataContract]
    public class Quote
    {
        [DataMember(Name = "lines")]
        public List<Line> Lines { get; set; }

        [DataMember(Name = "qconst")]
        public string Qconst { get; set; }
    }

    [DataContract]
    public class Line
    {
        [DataMember(Name = "stage")]
        public string Stage { get; set; }

        [DataMember(Name = "quote")]
        public string Quote { get; set; }

        [DataMember(Name = "chars")]
        public List<Char> Chars { get; set; }
    }

    [DataContract]
    public class Char
    {
        [DataMember(Name = "nconst")]
        public string Nconst { get; set; }

        [DataMember(Name = "@char")]
        public string Chars { get; set; }
    }
    
    [DataContract]
    public class Trailer
    {
        [DataMember(Name = "encodings")]
        public Encodings encodings { get; set; }

        [DataMember(Name = "description")]
        public string Description { get; set; }

        [DataMember(Name = "relatedTitle")]
        public RelatedTitle relatedTitle { get; set; }

        [DataMember(Name = "duration_seconds")]
        public int DurationSeconds { get; set; }

        [DataMember(Name = "slates")]
        public List<Slate> Slates { get; set; }

        [DataMember(Name = "content_type")]
        public string ContentType { get; set; }

        [DataMember(Name = "relatedName")]
        public RelatedName RelatedName { get; set; }

        [DataMember(Name = "id")]
        public string Id { get; set; }

        [DataMember(Name = "title")]
        public string Title { get; set; }

        [DataMember(Name = "@type")]
        public string Type { get; set; }
    }

    [DataContract]
    public class Encodings
    {
        [DataMember(Name = "H.264 Fire 600")]
        public Format H264Fire600 { get; set; }

        [DataMember(Name = "iPhone 3G")]
        public Format IPhone3G { get; set; }
    }

    [DataContract]
    public class IPhone3G
    {
        [DataMember(Name = "format")]
        public string Format { get; set; }

        [DataMember(Name = "url")]
        public string Url { get; set; }
    }

    [DataContract]
    public class Format
    {
        [DataMember(Name = "format")]
        public string Formats { get; set; }

        [DataMember(Name = "url")]
        public string Url { get; set; }
    }

    [DataContract]
    public class RelatedTitle
    {
        [DataMember(Name = "title")]
        public string Title { get; set; }

        [DataMember(Name = "type")]
        public string Type { get; set; }

        [DataMember(Name = "title_id")]
        public string TitleId { get; set; }

        [DataMember(Name = "year")]
        public string Year { get; set; }

        [DataMember(Name = "image")]
        public Image Image { get; set; }
    }

    [DataContract]
    public class RelatedName
    {
        [DataMember(Name = "nconst")]
        public string Nconst { get; set; }

        [DataMember(Name = "name")]
        public string Name { get; set; }

        [DataMember(Name = "image")]
        public Image Image { get; set; }
    }

    [DataContract]
    public class Slate // TODO ?= Image??
    {
        [DataMember(Name = "width")]
        public int Width { get; set; }

        [DataMember(Name = "url")]
        public string Url { get; set; }

        [DataMember(Name = "height")]
        public int Height { get; set; }
    }

    [DataContract]
    public class ReleaseDate
    {
        [DataMember(Name = "normal")]
        public string Normal { get; set; }
    }

    [DataContract]
    public class Runtime
    {
        [DataMember(Name = "time")]
        public int Time { get; set; }
    }

    [DataContract]
    public class CastSummary
    {
        [DataMember(Name = "char")]
        public string Char { get; set; }

        [DataMember(Name = "name")]
        public Name Name { get; set; }

        [DataMember(Name = "as")]
        public string As { get; set; }
    }

    [DataContract]
    public class Plot
    {
        [DataMember(Name = "outline")]
        public string Outline { get; set; }

        [DataMember(Name = "more")]
        public int More { get; set; }
    }

    [DataContract]
    public class News
    {
        [DataMember(Name = "channel")]
        public string Channel { get; set; }

        [DataMember(Name = "total")]
        public int Total { get; set; }

        [DataMember(Name = "sources")]
        public Sources Sources { get; set; }

        [DataMember(Name = "markup")]
        public string Markup { get; set; }

        [DataMember(Name = "label")]
        public string Label { get; set; }

        [DataMember(Name = "limit")]
        public int Limit { get; set; }

        [DataMember(Name = "start")]
        public int Start { get; set; }

        [DataMember(Name = "items")]
        public List<Item> Items { get; set; }

        [DataMember(Name = "@type")]
        public string Type { get; set; }
    }

    [DataContract]
    public class Sources
    {
        // TODO ??
    }

    [DataContract]
    public class Item
    {
        [DataMember(Name = "source")]
        public string Source { get; set; }

        [DataMember(Name = "head")]
        public string Head { get; set; }

        [DataMember(Name = "id")]
        public string Id { get; set; }

        [DataMember(Name = "datetime")]
        public string Datetime { get; set; }
    }
}
